import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import WindiCSS from 'vite-plugin-windicss'
import {resolve} from "path";
import {viteMockServe} from "vite-plugin-mock";

// https://vitejs.dev/config/
// export default defineConfig({
//   plugins: [vue(),WindiCSS()]
// })

export default ({command})=>{
  console.log(command,"启动命令是什么")
  return {
    plugins: [
      vue(),WindiCSS(),
      viteMockServe({
        // default
        mockPath: 'mock',
        localEnabled: command === 'serve',
      }),
    ],
    resolve: {
      alias: {
        '@': resolve(__dirname, 'src'),
      },
    },
    server: {
      open: false,
      port:5000,
      proxy: {
        '/proxy': {
          target: 'http://127.0.0.1:8000/',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/proxy/, '')
        },
      },
    },
  }
}